<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<div class="page_title">
	<s:if test="%{id == null}">
		Add new monitor definition
	</s:if>
	<s:else>
		Edit monitor definition '<s:property value="definition.name"/>'
	</s:else>
</div>

<div class="smallForm">
	<s:actionerror/>
	
	<s:if test="testComplete">
		<div class='<s:property value="testCss"/>'>
			<p>
				<s:if test="testCtx.success">
					Test execution finished successfully with the status 
				</s:if>
				<s:else>
					Test execution failed. Status is 
				</s:else>
				<b><span class='status<s:property value="testCtx.status"/>'><s:property value="testCtx.status"/></span></b>.
			</p>
			<p>
				Message is: '<span><s:property value="testCtx.message"/></span>'.
			</p>
			<s:if test="havingOutput">
				<table id="testOutput" width="90%" align="center">
					<tr>
						<th>Variable</th>
						<th>Key</th>
						<th>Value</th>
					</tr>
					<s:iterator value="testOutput">
						<tr>
							<td><s:property value="varName"/></td>
							<td><s:property value="key"/></td>
							<td><s:property value="value"/></td>
						</tr>
					</s:iterator>
				</table>
			</s:if>
		</div>
	</s:if>

	<s:form method="post" action="saveMonitorDefinition">
		<s:hidden name="definition.id"/>
		<s:textfield cssClass="txtlarge" name="definition.name" label="Name"/>
		<s:textarea cssClass="txtlarge" rows="6" name="definition.inputVariables" label="Input Variables"></s:textarea>
		<s:textarea cssClass="txtlarge" rows="10" name="definition.body" label="Body"></s:textarea>
		<s:textfield cssClass="txtlarge" name="testHost" label="Test Host"/>
		<s:component template="controlheader.ftl"/>
			<table width="100%">
				<tr>
					<td align="left">
						<s:submit action="testMonitorDefinition" theme="simple" cssClass="btn" value="%{'test'}" />
					</td>
					<td align="right">
						<s:submit theme="simple" cssClass="btn" value="%{'test and save'}" />
						<button class="btn" onclick="document.location='<s:url namespace="/admin" action="listMonitorDefinitions"/>'; return false;">cancel</button>
					</td>
				</tr>
			</table>
		<s:component template="controlfooter.ftl"/>
	</s:form>
</div>
